import type { RouteRecordRaw } from 'vue-router'
import { shallowRef } from 'vue'
import { Layout } from '../constant'
import IconMenuEnrollment from '~icons/local/menu-enrollment-color'
import IconMenuStudent from '~icons/local/menu-student'

// 报名招生
const enrollment: RouteRecordRaw = {
  path: 'enrollment',
  name: 'enrollment',
  meta: {
    title: '招生功能',
    group: true,
  },
  children: [
    {
      path: 'order/list',
      name: 'OrderIndex',
      component: () => import('@/views/shop/order/index.vue'),
      meta: {
        title: '订单列表',
        code: 'shop:order:manage',
        icon: 'icon-unordered-list',
      },
    },
    {
      path: 'order/create',
      name: 'OrderCreate',
      component: () => import('@/views/shop/order/create.vue'),
      meta: {
        title: '创建订单',
        code: 'shop:order:manage',
        icon: 'icon-plus',
      },
    },
    {
      path: 'order/detail',
      name: 'OrderDetail',
      component: () => import('@/views/shop/order/detail.vue'),
      meta: {
        title: '订单详情',
        code: 'shop:order:manage',
        icon: 'icon-dashboard',
        hidden: true,
      },
    },
    {
      path: 'student',
      name: 'Student',
      component: () => import('@/views/education/student/index.vue'),
      meta: {
        title: '学员列表',
        code: 'edu:student:manage',
        icon: shallowRef(IconMenuStudent),
      },
    },
    {
      path: 'student/detail',
      name: 'StudentDetail',
      component: () => import('@/views/education/student/StudentDetail.vue'),
      meta: {
        title: '学生详情',
        code: 'edu:student:manage',
        hidden: true,
      },
    },
  ],
}

// 营销功能
const marketing: RouteRecordRaw = {
  path: 'marketing',
  name: 'marketing',
  meta: {
    title: '营销功能',
    group: true,
  },
  children: [
    {
      path: 'coupon/template',
      name: 'CouponTemplateIndex',
      component: () => import('@/views/shop/coupon/index.vue'),
      meta: {
        title: '优惠券模板',
        code: 'shop:coupon:read',
        icon: 'icon-apps',
      },
    },
    {
      path: 'coupon/list',
      name: 'CouponList',
      component: () => import('@/views/shop/coupon/CouponList.vue'),
      meta: {
        title: '优惠券记录',
        code: 'shop:coupon:read',
      },
    },
    {
      path: 'activity/list',
      name: 'ActivityList',
      component: () => import('@/views/shop/activity/ActivityList.vue'),
      meta: {
        title: '营销活动',
        code: 'system:user:view',
        icon: 'icon-gift',
      },
    },
  ],
}

export default <RouteRecordRaw> {
  path: '/shop',
  component: Layout,
  meta: {
    title: '招生营销',
    icon: shallowRef(IconMenuEnrollment),
    sort: 2,
  },
  children: [
    enrollment,
    marketing,
  ],
}
